package com.jic.veteran.portal.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.jic.veteran.common.exception.ApiException;
import com.jic.veteran.mapper.*;
import com.jic.veteran.model.*;
import com.jic.veteran.portal.service.AlumniEnterpriseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 获取校友会介绍、规章、使用说明
 * Created by mars on 2021/11/10.
 */
@Slf4j
@Service
public class AlumniEnterpriseServiceImpl implements AlumniEnterpriseService {

    @Autowired
    private AlumniEnterpriseInformationMapper alumniEnterpriseInformationMapper;

    @Override
    public List<AlumniEnterpriseInformation> getEnterpriseList() {

        List<AlumniEnterpriseInformation> alumniEnterpriseInformation ;

        AlumniEnterpriseInformationExample alumniEnterpriseInformationExample = new AlumniEnterpriseInformationExample();
        AlumniEnterpriseInformationExample.Criteria criteria = alumniEnterpriseInformationExample.createCriteria();
        criteria.andStatusEqualTo(1);
        alumniEnterpriseInformationExample.setOrderByClause("enterprise_name desc");
        alumniEnterpriseInformation = alumniEnterpriseInformationMapper.selectByExampleWithBLOBs(alumniEnterpriseInformationExample);
        return alumniEnterpriseInformation;
    }

    @Override
    public AlumniEnterpriseInformation getEnterprisedDetail(Long id) {

        AlumniEnterpriseInformation alumniEnterpriseInformation ;
        AlumniEnterpriseInformationExample alumniEnterpriseInformationExample = new AlumniEnterpriseInformationExample();
        AlumniEnterpriseInformationExample.Criteria criteria = alumniEnterpriseInformationExample.createCriteria();
        criteria.andIdEqualTo(id);
        alumniEnterpriseInformation = alumniEnterpriseInformationMapper.selectByExampleWithBLOBs(alumniEnterpriseInformationExample).get(0);
        return alumniEnterpriseInformation;
    }
}
